package com.wang.openApiclientsdk.utils;

import cn.hutool.crypto.digest.DigestAlgorithm;
import cn.hutool.crypto.digest.Digester;
import lombok.extern.slf4j.Slf4j;

/**
 * 签名工具
 */
@Slf4j
public class SignUtils {
    /**
     * 生成签名
     * sign通过sk+请求body生成签名
     *
     * @param body
     * @param secretKey
     * @return
     */
    public static String getSign(String body, String secretKey) {
        log.info("getSign body：" + body);
        log.info("getSign secretKey：" + secretKey);
        Digester md5 = new Digester(DigestAlgorithm.SHA256);
        String content = body + "." + secretKey;
        String digestHex = md5.digestHex(content);

        return digestHex;
    }
}
